#ifndef DULINKLIST_H_
#define DULINKLIST_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "base.h"
#include "node.h"

typedef struct _tagDuLinkList {
    PDoublyLinkNode	header;
    int				length;
} DoublyLinkList, *PDoublyLinkList;

typedef BOOL ( * visit )( ElemType * );
BOOL DoublyLinkListOutPut( ElemType *e );

Status DoublyLinkListInit( PDoublyLinkList L );
Status DoublyLinkListUnInit( PDoublyLinkList L );
Status DoublyLinkListCreate( PDoublyLinkList L, ElemType *pVec, int length );
Status DoublyLinkListClear( PDoublyLinkList L );
Status DoublyLinkListGetElem( PDoublyLinkList L, int pos, ElemType *e );
Status DoublyLinkListSetElem( PDoublyLinkList L, int pos, ElemType e );
Status DoublyLinkListInsertElem( PDoublyLinkList L, int pos, ElemType e );
Status DoublyLinkListPushBack( PDoublyLinkList L, ElemType e );
Status DoublyLinkListDeleteElem( PDoublyLinkList L, int pos, ElemType *pe );
Status DoublyLinkListGetNode( PDoublyLinkList L, int pos, PDoublyLinkNode *ppNode );

int DoublyLinkListFindElem( PDoublyLinkList L, ElemType e );
int DoublyLinkListLength( PDoublyLinkList L );
BOOL DoublyLinkListEmpty( PDoublyLinkList L );
void DoublyLinkListTraverse( PDoublyLinkList L, visit pCallBack );
void DoublyLinkListTraverseBack( PDoublyLinkList L, visit pCallBack );

static void DoublyLinkListInsertNode( PDoublyLinkNode prior, PDoublyLinkNode pnew );

#ifdef __cplusplus
}
#endif

#endif